<include file="order@public/status"/>
<include file="public@header"/>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="{$tab=='index'?'active':''}"><a href="{:url('AdminOrder/index')}">所有订单</a></li>
    </ul>
    <form class="well form-inline margin-top-20" method="post" action="{:url('AdminOrder/'.$tab)}">
        订单编号：
        <input type="text" class="form-control" name="order_sn" style="width: 100px;"
               value="{:input('request.order_sn','')}" placeholder="订单编号">
        用户邮箱：
        <input type="text" class="form-control" name="email" style="width: 100px;" value="{:input('request.email','')}"
               placeholder="请输入邮箱">
        用户手机：
        <input type="text" class="form-control" name="mobile" style="width: 100px;"
               value="{:input('request.mobile','')}" placeholder="请输入手机">
        <input type="submit" class="btn btn-primary" value="搜索"/>
        <a class="btn btn-danger" href="{:url('AdminOrder/'.$tab)}">清空</a>
    </form>

    <form method="post" class="js-ajax-form">
        <div class="table-actions">
            <!--<button class="btn btn-primary btn-sm js-ajax-submit" type="submit" data-action="" data-subcheck="true" data-msg="你确定合并开票吗？">合并开票</button>-->
            <button class="btn btn-danger btn-sm js-ajax-submit" type="submit" data-action="" data-subcheck="true" data-msg="你确定删除吗？">删除</button>
        </div>
        <table class="table table-hover table-bordered table-list">
            <thead>
            <tr>
                <th width="16">
                    <label>
                        <input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x">
                    </label>
                </th>
                <th>订单号</th>
                <th>用户</th>
                <!--<th>客户</th>-->
                <!--<th>单位</th>-->
                <!-- <th>收件人</th>
                <th>物流名称</th> -->
                <!--<th>支付方式</th>-->
                <th>下单时间</th>
                <!--<th>过期时间</th>-->
                <th>订单总价</th>
                <th>应收款</th>
                <th>来源</th>
                <th>{:lang('STATUS')}</th>
                <th align="center">{:lang('ACTIONS')}</th>
            </tr>
            </thead>
            <tbody>

            <foreach name="orders" item="vo">
                <tr>
                    <td>
                        <input type="checkbox" class="js-check" data-yid="js-check-y" data-xid="js-check-x" name="ids[]"
                               value="{$vo.id}">
                    </td>
                    <td>
                        <a href="javascript:;" onclick="openDetailDialog(this);" data-id="{$vo.id}"
                           data-toggle="tooltip" title="订单详情">
                            {$vo.order_sn}
                        </a>
                        <notempty name="vo.parent_id">
                            <!--<span class="label label-warning">子订单</span>-->
                        </notempty>
                    </td>
                    <td>
                        用户ID:{$vo.user_id}
                        <notempty name="vo.user.user_nickname">
                            <br>昵称:{$vo.user.user_nickname}
                        </notempty>
                        <notempty name="vo.user.mobile">
                            <br>手机:{$vo.user.user_login}
                        </notempty>
                        <notempty name="vo.user.user_email">
                            <br>邮箱:{$vo.user.user_email}
                        </notempty>
                        <notempty name="vo.user.mobile">
                            <br>手机:{$vo.user.mobile}
                        </notempty>
                    </td>
                    <!--
                    <td>
                        {$customers[$vo['user_id']]['name']|default=''} <br>
                        {$customers[$vo['user_id']]['mobile']|default=''} <br>
                        {$customers[$vo['user_id']]['email']|default=''}
                    </td>
                    <td>
                        {$customers[$vo['user_id']]['company']|default=''}
                    </td>
                    -->
                    <!-- <td>{$vo.consignee}</td>
                    <td>{$vo.shipment_name}</td> -->
                    <!--<td>{$vo.payment_name}</td>-->
                    <td>{:date('Y-m-d H:i',$vo['create_time'])}</td>
                    <!--
                    <td>
                        <empty name="vo.expire_time">

                            <else/>
                            {:date('Y-m-d H:i',$vo['expire_time'])}
                        </empty>
                    </td>
                    -->
                    <td>￥{$vo.total_amount}</td>
                    <td>￥{$vo.order_amount}</td>
                    <td>
                        <empty name="vo.source">
                            官网
                            <else/>
                            {$vo.source}
                        </empty>
                    </td>
                    <td>
                        {$user_confirmed[$vo['user_confirmed']]}<br>
                        {$pay_status[$vo['pay_status']]}<br>
                        {$shipping_status[$vo['shipping_status']]}<br>
                        {$order_status[$vo['order_status']]}
                    </td>
                    <td>
                        <!--<a href="{:url('AdminOrder/sendConfirmEmail')}?order_id={$vo.id}" class="js-ajax-dialog-btn"-->
                           <!--data-msg="您确定发送确认邮件吗？" data-toggle="tooltip" title="发送确认邮件"><i class="fa fa-envelope-o"></i>&nbsp;邮件确认</a><br>-->
                        <a href="{:url('AdminOrder/readyToShip')}?id={$vo.id}" class="js-ajax-dialog-btn"
                           data-msg="您确定要申请发货吗？" data-toggle="tooltip" title="申请发货"><i class="fa fa-truck"></i>&nbsp;申请发货</a><br>
                        <!--<a href="{:url('AdminOrder/downloadInvoice')}?order_id={$vo.id}" target="_blank"-->
                           <!--data-toggle="tooltip" title="下载合同"><i class="fa fa-file-text-o"></i>&nbsp;生成合同</a><br>-->
                        <a href="{:url('AdminOrder/applyPrintInvoice')}?order_id={$vo.id}" class="js-ajax-dialog-btn"
                           data-msg="您确定要申请开票吗？" data-toggle="tooltip" title="申请开票"><i class="fa fa-ticket"></i>&nbsp;申请开票</a>
                    </td>
                </tr>
            </foreach>
            </tbody>
            <tfoot>
            <tr>
                <th width="16">
                    <label>
                        <input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x">
                    </label>
                </th>
                <th>订单号</th>
                <th>用户</th>
                <!--<th>客户</th>-->
                <!--<th>单位</th>-->
                <!-- <th>收件人</th>
                <th>物流名称</th> -->
                <!--<th>支付方式</th>-->
                <th>下单时间</th>
                <!--<th>过期时间</th>-->
                <th>订单总价</th>
                <th>应收款</th>
                <th>来源</th>
                <th>{:lang('STATUS')}</th>
                <th align="center">{:lang('ACTIONS')}</th>
            </tr>
            </tfoot>
        </table>
        <ul class="pagination">{$page}</ul>
    </form>
</div>
<script src="__STATIC__/js/admin.js"></script>
<script>
    function openDetailDialog(obj) {
        var $obj  = $(obj);
        var id    = $obj.data('id');
        var title = $obj.data('title');
        parent.openIframeLayer("{:url('AdminOrder/detail')}?id=" + id, '订单详情', {
            area: ['95%', '90%'],
            btn: ['确定', '取消'],
            yes: function (index, layero) {
                console.log(layero);
                var iframeWin = parent.window[layero.find('iframe')[0]['name']];
                //iframeWin.confirm();
                parent.layer.close(index); //如果设定了yes回调，需进行手工关闭
            }
        });
    }
</script>
</body>
</html>